namespace PcapDotNet.Packets.IpV6
{
    /// <summary>
    /// RFC 4866.
    /// <pre>
    /// +-----+-------------+---------------+
    /// | Bit | 0-7         | 8-15          |
    /// +-----+-------------+---------------+
    /// | 0   | Option Type | Opt Data Len  |
    /// +-----+-------------+---------------+
    /// | 16  | Permanent Home Keygen Token |
    /// | ... |                             |
    /// +-----+-----------------------------+
    /// </pre>
    /// </summary>
    [IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.PermanentHomeKeygenToken)]
    public sealed class IpV6MobilityOptionPermanentHomeKeygenToken : IpV6MobilityOptionSingleDataSegmentField
    {
        /// <summary>
        /// Creates an option from the given permanent home keygen token.
        /// </summary>
        /// <param name="permanentHomeKeygenToken">
        /// Contains the permanent home keygen token generated by the correspondent node.
        /// The content of this field must be encrypted with the mobile node's public key.
        /// The length of the permanent home keygen token is 8 octets before encryption, though the ciphertext and, hence,
        /// the Permanent Home Keygen Token field may be longer.
        /// </param>
        public IpV6MobilityOptionPermanentHomeKeygenToken(DataSegment permanentHomeKeygenToken)
            : base(IpV6MobilityOptionType.PermanentHomeKeygenToken, permanentHomeKeygenToken)
        {
        }

        /// <summary>
        /// Contains the permanent home keygen token generated by the correspondent node.
        /// The content of this field must be encrypted with the mobile node's public key.
        /// The length of the permanent home keygen token is 8 octets before encryption, though the ciphertext and, hence,
        /// the Permanent Home Keygen Token field may be longer.
        /// </summary>
        public DataSegment PermanentHomeKeygenToken
        {
            get { return Value; }
        }

        internal override IpV6MobilityOption CreateInstance(DataSegment data)
        {
            return new IpV6MobilityOptionPermanentHomeKeygenToken(data);
        }

        private IpV6MobilityOptionPermanentHomeKeygenToken()
            : this(DataSegment.Empty)
        {
        }
    }
}